package com.xyh.controller;

import com.xyh.po.User;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * @Author:kyle
 * @Date:2020/12/16 - 22:28
 * @Project:spring_demo1
 * @Package:com.xyh.controller
 * @Version:1.0
 */
@Controller("userController")
public class UserController {

    @RequestMapping("/userList")
    public String getAll(ModelMap model){

        model.addAttribute("name","熊大");
        return "user";
    }

    @RequestMapping("/jump")
    public String jump(){

        //return "redirect:login.jsp";//重定向，不受配置前后缀影响
        return "forward:login.jsp";//请求转发，属于服务器内部的跳转，一次请求，地址栏不会发生变化
    }

    @RequestMapping("/login")
    public String login(String username,String password){
        System.out.println("username = " + username);
        System.out.println("password = " + password);

        return "redirect:index.jsp";
    }

    @RequestMapping("/loginUser")
    public String loginUser(User user){
        System.out.println("username = " + user.getUsername());
        System.out.println("password = " + user.getPassword());

        return "redirect:index.jsp";
    }
}
